/**
 * @file sessionfactory.h
 * @brief SessionFactory class interface
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3 of the License.
 *
 * @author VestniK (Sergey N.Vidyuk) sir.vestnik@gmail.com
 * @date 16 Jan 2010
 */
#ifndef MJN_SESSIONFACTORY_H
#define MJN_SESSIONFACTORY_H

#include <QtCore/QObject>
#include <QtCore/QtGlobal>
#include <QtCore/QPointer>
#include <QtCore/QMap>
#include <QtCore/QUuid>

#include "session.h"

namespace mjn {

    class Game;
    class ServerPlayer;

    class SessionData {
        public:
            ServerPlayer *player;
            QPointer<Session> session;
            bool disconnected;
    };

    class SessionFactory : public QObject {
        Q_OBJECT
        public:
            explicit SessionFactory(Game *game);
            virtual ~SessionFactory() {};

            Session *create();

            bool storeData(const QUuid &sid, const SessionData &data);
            SessionData *getData(const QUuid &sid);
            void removeData(const QUuid &sid);

            Game *game() {return mGame;}
        public slots:
            void notifySessions();
        private:
            Q_DISABLE_COPY(SessionFactory);
            Game *mGame;
            QMap< QUuid,SessionData > mSessionsDataMap;
    };

}

#endif // MJN_SESSIONFACTORY_H
